package com.zhy.http.okhttp.callback;

import android.text.TextUtils;

import com.zhy.http.okhttp.utils.AesUtil;

import org.json.JSONException;
import org.json.JSONObject;
import org.w3c.dom.Text;

import java.io.IOException;

import okhttp3.Response;

/**
 * Created by zhy on 15/12/14.
 */
public abstract class StringCallback extends Callback<String> {
    @Override
    public String parseNetworkResponse(Response response) throws IOException {
        String respinseData = response.body().string();
        if (!TextUtils.isEmpty(respinseData)) {
            try {
                JSONObject jsonObject = new JSONObject(respinseData);
                try {
                    String code = jsonObject.getString(AesUtil.encrypt("code").trim());
                    String data = jsonObject.getString(AesUtil.encrypt("data").trim());
                    String message = jsonObject.getString(AesUtil.encrypt("message").trim());

                } catch (Exception e) {
                    e.printStackTrace();
                }
            } catch (JSONException e) {
                e.printStackTrace();
            }

        }
        return response.body().string();
    }


}
